package client.comm.baoding.ui.me

import android.content.Intent
import android.view.View
import androidx.lifecycle.Observer
import client.comm.baoding.BaseMiddleActivity
import client.comm.baoding.R
import client.comm.baoding.api.event.EventUserInfo
import client.comm.baoding.databinding.ActivityRealnameVerifyBinding
import client.comm.baoding.ui.WebActivity
import client.comm.baoding.ui.vm.RegisterViewModel
import client.comm.commlib.dialog.CameraOrSelectDialog
import client.comm.commlib.toast.toast
import org.greenrobot.eventbus.EventBus

class RealNameVerifyActivity :
    BaseMiddleActivity<RegisterViewModel, ActivityRealnameVerifyBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_realname_verify
    }

    override fun initViewModel(): RegisterViewModel = createViewModel()

    override fun initView() {
        binding?.apply {
            login = this@RealNameVerifyActivity
            vm = viewModel

        }
    }

    override fun observerUI() {
        viewModel.realNameVerifyRet.observe(this, Observer {
            it?.apply {
                if (isSuccess) {
                    startActivity(Intent(this@RealNameVerifyActivity, WebActivity::class.java).apply {
                        putExtra("adInfo", it.data?.sand_url)
                        putExtra("title", "实名认证")
                    })
                    finish()
                } else {
                    toast(it.message)
                }
            }
        })
    }


}